package com.neo.base.actorTest2

/**
  * Created by hadoop on 6/15/17.
  */

import scala.actors.Actor._

object ActorCountTest {
  def main(args: Array[String]): Unit = {

    println(counter(34566))
    actorMutest(10)
  }

  def counter(numbers: Int) ={

    (0 /: (1 to numbers)){(total,number) => total + number}

  }

  def actorMutest(number: Int){
    val caller = self
    var startTime : Long = 0
    for(i <- 1 to number) {
      actor {

        caller ! "Helll +" + i
        Thread.sleep(30000)
      }

      println(i)
    }

    for(i <- 1 to number) {
      receive {
        case msg =>
          val receivedTime = System.currentTimeMillis() - startTime
          println("Received message " + msg + " after " + receivedTime + " ms")
      }
    }
  }
}
